package com.blog.controller.frontpage;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blog.controller.base.BaseServlet;
import com.blog.entity.DraftEntity;
import com.blog.entity.UserLoginEntity;
import com.blog.service.frontpage.PersonalCenterService;

@WebServlet("/newessayDraft")
public class NewessayDraftSevlet extends BaseServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		UserLoginEntity user=(UserLoginEntity )req.getSession().getAttribute("user");
		int userid=user.getUser_id();
		PersonalCenterService service=PersonalCenterService.getInstance();
		List<DraftEntity> drafts=service.getDraftById(userid);
		req.setAttribute("drafts", drafts);
		forward("frontpage/newessay_draft");
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
}